import 'package:elevator_app/common/my_icon.dart';
import 'package:elevator_app/config/global_config.dart';
import 'package:elevator_app/utils/screenutil/fit.dart';
import 'package:flutter/material.dart';

class BaseCheckbox extends StatelessWidget {
  // 选中状态
  bool checkedStatus;

  // 回调函数
  Function onChanged;

  BaseCheckbox({bool checkedStatus, Function onChanged})
      : this.checkedStatus = checkedStatus ?? false,
        this.onChanged = onChanged;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        this.checkedStatus = !checkedStatus;
        // 向外界通知
        onChanged(this.checkedStatus);
      },
      child: Container(
        width: 180.f,
        height: 50.f,
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              width: 30.f,
              height: 30.f,
              margin: EdgeInsets.only(right: 10.f),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(5.f),
                color: this.checkedStatus ? GlobalConfig.theme : null,
                border: Border.all(
                  width: 2.f,
                  color: this.checkedStatus
                      ? GlobalConfig.theme
                      : GlobalConfig.borderColor,
                ),
              ),
              child: this.checkedStatus
                  ? Icon(
                      MyIcon.success,
                      size: 14.f,
                      color: Colors.white,
                    )
                  : null,
            ),
            Text(
              "记住密码",
              style: TextStyle(
                fontSize: 26.f,
                color: Colors.black26,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
